package tech.yangzhijie.basic;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.junit.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;

public class Tests {
    @Test
    public void method01(){
        List<Map<String,String>> maps = new ArrayList<>();
        Map<String,String> map = new HashMap();
        map.put("1","2");
        map.put("2","3");
        map.put("5","5");
        Map<String,String> map2 = new HashMap();
        map2.put("1","2");
        map2.put("2","3");
        map2.put("5","5");
        maps.add(map);
        maps.add(map2);
        HashMap<String,String>[] hashMaps = maps.toArray(new HashMap[]{});
        for (HashMap hashMap : hashMaps) {
            hashMap.forEach((k,v)->{
                System.out.println(k+"--"+v);
            });
        }
    }

    @Test
    public void method02(){
        String localDate = LocalDate.ofYearDay(2018,-100).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        System.out.println(localDate);
    }

    @Test
    public void method03(){
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);
        System.out.println(System.currentTimeMillis());
    }

    /**
     * @author: 快乐在角落里
     * @create: 2018-12-21 20:20
     */
    @Test
    public void method04() {
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli());
        System.out.println(localDate.atStartOfDay().toEpochSecond(ZoneOffset.of("+8")));
    }
}
